package com.cruising.backend.config;
import com.cruising.backend.interceptors.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 设置拦截的路径
        registry.addInterceptor(loginInterceptor)
                .excludePathPatterns(// 不拦截这些路径
                        "/admin/login",    // 管理员登录
                        "/users/submit",     // 用户举报
                        "/verify/code/createShearCaptcha",   // 验证码生成
                        "/verify/code/verify",   // 验证码验证
                        "/reports/submit/{department}"

                );
    }
}
